--time.lua

local DAY_MS = 86400000           --1天（ms）

_G.time = {}
function time.tstostr(timestamp)
    return os.date("%Y-%m-%d %H:%M:%S", timestamp)
end

function time.sectostr(seconds)
    local hours = math.floor(seconds / 3600)
    local minutes = math.floor((seconds % 3600) / 60)
    local secs = seconds % 60
    return string.format("%d时%d分", hours, minutes)
end

function time.gamesec_tostr(seconds)
    local year = (seconds // (DAY_MS * (28 * 4)) + 1)
    local month = ((seconds // (DAY_MS * 28)) % 4 + 1)
    local day = (seconds // DAY_MS + 1)
    return string.format("%d年%d月%d日", year, month, day)
end